package org.example.utils;

import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.JWTParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JwtUtils {
    private static final Logger log = LoggerFactory.getLogger(JwtUtils.class);
    public static void checkToken(String token){
        try {
            JWTClaimsSet claimsSet = JWTParser.parse(token).getJWTClaimsSet();
            log.info("claimsSet = {}",claimsSet);
            log.info("claimsSet = {}",claimsSet.toString());
        }catch (Exception e){
            log.info("解密token失败");
            e.printStackTrace();
        }
    }

    public static void main(String... args){
        String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODEzMDk1MjIsInVzZXJfbmFtZSI6InRlc3QiLCJhdXRob3JpdGllcyI6WyJXUiJdLCJqdGkiOiIxZmM0MjhlZS1mZTE2LTQ1NzEtYmMyMC0yMjFhYjk4OTEzMzQiLCJjbGllbnRfaWQiOiJvYXV0aCIsInNjb3BlIjpbImFsbCIsImFwcHJvdmUiXX0.xCVO_G4Zk4x-NX4QLLiZQ_W3ylVztY09S05RAEFdlFM";
        checkToken(token);
    }
}
